Skip to content

HTTP/3: Eliminate near-zero "wait for connection" telemetry signals#114083

Merged
ManickaP merged 15 commits into
dotnet:mainfrom
antonfirsov:h3-telemetry-0
Apr 25, 2025
Merged

HTTP/3: Eliminate near-zero "wait for connection" telemetry signals#114083
ManickaP merged 15 commits into
dotnet:mainfrom
antonfirsov:h3-telemetry-0

Conversation

@antonfirsov

@antonfirsov antonfirsov commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

We should only emit wait for connection activities, metrics and events when (1) there is no HTTP/3 connection (2) OpenOutboundStreamAsync() is expected to wait for available streams. When there is a usable connection in the pool, emitting near-zero spans is not consistent with telemetry for other HTTP versions and adds noise.

Fixes #104783.

@antonfirsov antonfirsov added this to the 10.0.0 milestone Mar 31, 2025
@antonfirsov antonfirsov requested review from a team, ManickaP and Copilot March 31, 2025 21:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the "wait for connection" telemetry logic for HTTP/3, ensuring such telemetry is only emitted for new connections where OpenOutboundStreamAsync() is expected to wait.

  • Updated test cases in MetricsTest.cs and DiagnosticsTests.cs to reflect the new telemetry behavior.
  • Refactored Http3Connection.SendAsync and associated telemetry tracking via a new WaitForHttp3ConnectionActivity structure.
  • Adjusted HttpConnectionPool.Http3.cs to integrate the new telemetry mechanism and removed obsolete timestamp parameters.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs Added a test to ensure queue time is measured only for the first connection.
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs Updated expected telemetry count in diagnostics tests.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs Refactored SendAsync to use WaitForHttp3ConnectionActivity and updated telemetry logic.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionWaiter.cs Added a comment to clarify custom telemetry behavior for HTTP/3 connections.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http3.cs Switched to the new telemetry mechanism and removed obsolete parameters.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/ConnectionSetupDistributedTracing.cs Exposed a new method to check for telemetry listeners.

@azure-pipelines

This comment was marked as outdated.

@ManickaP ManickaP left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!
:shipit:
If you don't merge it byt the end of the day because you're already OOF, I'll merge it myself.

@ManickaP

Copy link
Copy Markdown
Member

@pavelsavara Seems like your new test in https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http/tests/TrimmingTests/MetricsHandlerTrimmedTest.cs is failing on this PR. Would be able to help with resolving it?

@pavelsavara

Copy link
Copy Markdown
Member

Would be able to help with resolving it?

Probably the new code keeps the metrics classes alive.

You can run the test and see which dependencies are doing it by looking at artifacts\bin\trimmingTests\projects\System.Net.Http.TrimmingTests\MetricsHandlerTrimmedTest\win-x64\obj\Release\net10.0\win-x64\linked\linker-dependencies.xml

I suspect that the new code in WaitForHttp3ConnectionActivity is touching Settings._metrics without GlobalHttpSettings.MetricsHandler.IsGloballyEnabled guard. The trimmer is not very smart.

@pavelsavara

Copy link
Copy Markdown
Member

.\dotnet.cmd build src\libraries\System.Net.Http\tests\TrimmingTests\System.Net.Http.TrimmingTests.proj -c Release /p:TestTrimming=true

@antonfirsov

Copy link
Copy Markdown
Contributor Author

The trimmer issue should be fixed by cf00150. Good that #114326 included all the types in the trimming tests!

@antonfirsov

Copy link
Copy Markdown
Contributor Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[H/3] Distributed Tracing / Telemetry

4 participants